<?php
class MemSession {
	
	public  $key;
	
	function __construct($key = ''){
		if($key == ''){
			$this->key = $this->get_key();
		}else{
			$this->key = $key;
		}
	}
	
	function __call($method,$params){
		switch ($method){
			case 'destroy':
				if(count($params) > 0)
					unset($_SESSION[$this->key][$params[0]]);
				else
					unset($_SESSION[$this->key]);
		}
	}
	function get_key(){
		$array = explode('/', $_SERVER['PHP_SELF']);
		return $array[count($array)-2];
		
	}

	function __get($attribute){
    	if(array_key_exists($attribute,$_SESSION[$this->key]))
	    	return $_SESSION[$this->key][$attribute];
		else
			return false;
    }
    
    function __set($attribute,$value){
    	$_SESSION[$this->key][$attribute] = $value;
		return true;
    }
    
    
}